﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
//using System.Net;
//using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace AVAilableRooms.Services
{
    //public static class CertificateValidation
    //{
    //    public static void SetCallBack()
    //    {
    //        ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallback;
    //    }

    //    private static bool CertificateValidationCallBack(
    //             object sender,
    //             System.Security.Cryptography.X509Certificates.X509Certificate certificate,
    //             System.Security.Cryptography.X509Certificates.X509Chain chain,
    //             System.Net.Security.SslPolicyErrors sslPolicyErrors)
    //    {
    //        // If the certificate is a valid, signed certificate, return true.
    //        if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
    //        {
    //            return true;
    //        }
    //        // If there are errors in the certificate chain, look at each error to determine the cause.
    //        if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
    //        {
    //            if (chain != null && chain.ChainStatus != null)
    //            {
    //                foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
    //                {
    //                    if ((certificate.Subject == certificate.Issuer) &&
    //                       (status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
    //                    {
    //                        // Self-signed certificates with an untrusted root are valid.
    //                        continue;
    //                    }
    //                    else
    //                    {
    //                        if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
    //                        {
    //                            // If there are any other errors in the certificate chain, the certificate is invalid,
    //                            // so the method returns false.
    //                            return false;
    //                        }
    //                    }
    //                }
    //            }
    //            // When processing reaches this line, the only errors in the certificate chain are
    //            // untrusted root errors for self-signed certificates. These certificates are valid
    //            // for default Exchange Server installations, so return true.
    //            return true;
    //        }
    //        else
    //        {
    //            // In all other cases, return false.
    //            return false;
    //        }
    //    }
    //}
}
